
gen month = mofd(encdate)


gen dow = dow(encdate)
egen hym  = group(month clinic)
egen hd = group(clinic dow)
gen temp_dx3 = substr(dx1,1,3)
egen diag = group(temp_dx3)





*drop missing and singleton observations that won't be included in regressions
keep if !mi(age_bin) & !mi(mos) & !mi(longevity) & !mi(married) & !mi(junior) & !mi(college) & !mi(race_white) & !mi(female) & !mi(diag) & !mi(afqt_p)
gen include = 1
foreach i in diag mos hym hd {
bys `i': replace include = 0 if _N == 1
}
keep if include == 1









reghdfe ed_prescription i.age_bin race_white female junior_enlisted college married longevity afqt_p, absorb(hym hd diag mos) res(residual)
egen propensity = mean(residual), by(provID year)









